package com.google.code.echronos;

import java.util.ArrayList;
import java.util.List;

public final class ListingEventConsumer implements EventConsumer {
	private List<Event> events = new ArrayList<>();

	@Override
	public void consumeEvent(final Event event) {
		events.add(event);
	}

	public Event getLastEvent() {
		if (events.size() == 0) {
			throw new IllegalStateException("No event received.");
		}
		return events.get(0);
	}

	public List<Event> getEvents() {
		return events;
	}
}
